package com.heima.admin.controller.v1;

import com.heima.admin.service.AdSensitiveService;
import com.heima.model.admin.dtos.SensitiveDTO;
import com.heima.model.admin.pojo.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author by jojo
 * @Date 2022/2/26
 * @Description
 */
@RestController
@RequestMapping("/api/v1/sensitive")
@Api(value = "敏感词管理API",tags = "敏感词管理API")
public class AdSensitiveController {
    @Autowired
    private AdSensitiveService adSensitiveService;

    @DeleteMapping("/del/{id}")
    @ApiOperation("删除敏感词")
    public ResponseResult deleteById(@PathVariable("id") Integer id){
        return adSensitiveService.deleteById(id);
    }

    @PostMapping("/list")
    @ApiOperation("敏感词分页查询")
    public ResponseResult findByNameAndPage(@RequestBody SensitiveDTO sensitiveDTO){
        return adSensitiveService.findByNameAndPage(sensitiveDTO);
    }

    @PostMapping("/save")
    @ApiOperation("新增敏感词")
    public ResponseResult addSensitive(@RequestBody AdSensitive sensitive){
        return adSensitiveService.addSensitive(sensitive);
    }
    @PostMapping("/update")
    @ApiOperation("修改敏感词")
    public ResponseResult updateBySensitive(@RequestBody AdSensitive sensitive){
        return adSensitiveService.updateBySensitive(sensitive);
    }
    @PostMapping("/sensitives")
    @ApiOperation("查询所有敏感词")
    public ResponseResult<List<String>> findByList(){
        return adSensitiveService.findByList();
    }
}
